package com.zfj.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author zfj
 * @date 2022/7/13 -22:36
 */
@Configuration
public class MyRedissonConfig {


	/**
	 * 所有对Redisson的使用都是基于RedissonClient对象
	 * @return
	 * @throws IOException
	 */
	@Bean(destroyMethod = "shutdown")
	public RedissonClient redisson() throws IOException{
		Config config = new Config();
		//Redis url should start with redis:// or rediss:// (for SSL connection)
		config.useSingleServer().setAddress("redis://192.168.78.138:6379");
				//集群模式
//				.useClusterServers()

		//根据Config创建RedissonClient实例
		return Redisson.create(config);
	}
}
